// CViewAdj.cpp : implementation file
//

#include "stdafx.h"
#include "PanImage.h"
#include "ViewAdj.h"

#include "MainFrm.h"

#include "DD_AnalyCfg.h"
#include "DDErrorDefine.h"
#include "MyDefineHeader.h"

/////////////////////////////////////////////////////////////////////////////
// CViewAdj

IMPLEMENT_DYNCREATE(CViewAdj, CMyFormView)

CViewAdj::CViewAdj()
	: CMyFormView()
{
	//{{AFX_DATA_INIT(CViewAdj)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

}

CViewAdj::~CViewAdj()
{
}

void CViewAdj::DoDataExchange(CDataExchange* pDX)
{
	CMyFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CViewAdj)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CViewAdj, CMyFormView)
	//{{AFX_MSG_MAP(CViewAdj)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CViewAdj diagnostics

#ifdef _DEBUG
void CViewAdj::AssertValid() const
{
	CMyFormView::AssertValid();
}

void CViewAdj::Dump(CDumpContext& dc) const
{
	CMyFormView::Dump(dc);
}
#endif //_DEBUG

void CViewAdj::Initialize()
{
	m_pRuler = &(g.MainWnd->m_AnalyRulers[eAnalyWindow_Adj]);
	s.ImgAnaly.SetHwnd( eAnalyWindow_Adj, m_hWnd );
	m_bInit = true ;
}


/////////////////////////////////////////////////////////////////////////////
// CViewAdj message handlers

void CViewAdj::OnDraw(CDC* /*pDC*/)
{
	// TODO: Add your specialized code here and/or call the base class
	if( !m_bInit )
	{
		return;
	}

	DDOnDraw();
}

void CViewAdj::DDOnDraw()
{
	POINT tScrollPos      = (POINT)GetScrollPosition();

	zkImgDraw xImgDraw;
	xImgDraw.nScrollx    = tScrollPos.x;
	xImgDraw.nScrolly    = tScrollPos.y;
	xImgDraw.fZoomFactor = m_fZoomFactor;

	s.ImgAnaly.Draw(eAnalyWindow_Adj,&xImgDraw);
}

void CViewAdj::ZoomOut()
{
	m_fZoomFactor *= MouseWheelZoomRate;
	InvalidateView();
	g.ViewmAnaly[eAnalyWindow_Ref]->InvalidateView(m_fZoomFactor);
	g.ViewmAnaly[eAnalyWindow_Sap]->InvalidateView(m_fZoomFactor);
	g.ViewmAnaly[eAnalyWindow_Sub]->InvalidateView(m_fZoomFactor);
}

void CViewAdj::ZoomIn()
{
	m_fZoomFactor /= MouseWheelZoomRate;
	InvalidateView();
	g.ViewmAnaly[eAnalyWindow_Ref]->InvalidateView(m_fZoomFactor);
	g.ViewmAnaly[eAnalyWindow_Sap]->InvalidateView(m_fZoomFactor);
	g.ViewmAnaly[eAnalyWindow_Sub]->InvalidateView(m_fZoomFactor);
}



void CViewAdj::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	CPoint Pt = point;
	GetImageXY(Pt);

	if( IsInside( Pt.x,Pt.y ) )
	{
		
	}

	CMyFormView::OnMouseMove(nFlags, point);
}
void CViewAdj::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
	CPoint Pt = point;
	GetImageXY( Pt );
	if( IsInside( Pt.x,Pt.y ) )
	{
		
	}

	SetCapture(); 

	CMyFormView::OnLButtonDown(nFlags, point);
}
void CViewAdj::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	g.MainWnd->PostMessage(WM_USER_ZoomAnalyView,eAnalyWindow_Adj,0);
	CMyFormView::OnLButtonDblClk(nFlags, point);
}
void CViewAdj::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default

	CPoint Pt = point;
	GetImageXY(Pt);

	if( IsInside( Pt.x,Pt.y ) )
	{	
		
	}


	ReleaseCapture();

	CMyFormView::OnLButtonUp(nFlags, point);
}




int CViewAdj::DXOnDraw(HDC hDc,int nWidth,int nHeight,DWORD dwDispType)
{
	

	return 0;
}
